﻿using System;
using System.Globalization;
using System.Windows.Data;
using Asistente.Model.Representation;

namespace Asistente.Converters
{
    public class IsEnabledNewUseCaseButton : IMultiValueConverter
    {
        /// <summary>
        /// This method return true if it's selected a use case pattern and a use case layout combintaion.
        /// </summary>
        /// <param name="values"> </param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns>True if the combination of useCase Pattern and layout are valid</returns>
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if ((Boolean)values[0])//SelectedUseCasePattern
            {
                UseCasePattern pattern = (UseCasePattern)values[1];//UseCasePattern
                if ((pattern.Equals(UseCasePattern.New)) || (pattern.Equals(UseCasePattern.Update)) || (pattern.Equals(UseCasePattern.PhysicalDelete)) || (pattern.Equals(UseCasePattern.LogicDelete)) || (pattern.Equals(UseCasePattern.View)))
                {
                    if ((Boolean)values[2])//SelectedUseCaseLayout
                    {
                        return true;
                    }
                }
                else
                {
                    return true;
                }
            }
            else
            {
                return false;
            }
            return false;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

    }
}
